<%@ page language="java" pageEncoding="utf-8"%>
<%@page import="com.wu24.bean.*,com.wu24.service.GoodsService,java.math.BigDecimal,java.util.*,java.util.Map.Entry"%>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>  
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="css/owl.carousel.css">
    <link rel="stylesheet" href="css/responsive.css">  
     <link rel="stylesheet" href="css/bootstrap.min.css">
      <link rel="stylesheet" href="style.css">
 </head>
<body>

<div class="header-area">
        <div class="container">
            <div class="row">
                <div class="col-md-8">
                    <div class="user-menu">
                        <ul>
                            <li><a href="#"><i class="fa fa-user"></i>欢迎<%=((User)session.getAttribute("user")).getUserName() %>登录</a></li>  
                        </ul>
                  </div>
                </div>               
            </div>
        </div>
    </div> <!-- End header area -->
    
    <div class="site-branding-area">
        <div class="container">
            <div class="row">
                <div class="col-sm-6">
                    <div class="logo">
                        <h1><a href="index.html"><span>西北大学二手交易市场</span></a></h1>
                    </div>
                </div>
                
              <div class="col-sm-6">
                <p>&nbsp;</p>
                  <p>&nbsp;</p>
                <p>寻你所想 如你所愿
                </p>
              </div>
            </div>
        </div>
    </div> <!-- End site branding area -->
    
    <div class="mainmenu-area">
        <div class="container">
            <div class="row">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                </div> 
                <div class="navbar-collapse collapse">
                    <ul class="nav navbar-nav">
                         <li><a href="main.jsp">首页</a></li>
                        <li ><a href="shop.jsp">逛一逛</a></li>                
                        <li><a href="cart.jsp">购物车</a></li>
                        <li><a href="upload.jsp">上传商品</a></li>
                        <%
                          String type=request.getParameter("type");
                          String tittle=null; 
                          String key=request.getParameter("key");
                          if(type.equals("0")){
                        	  tittle="书籍";
                          }
                          else if(type.equals("1")){
                        	  tittle="数码";
                          }
                          else if(type.equals("2"))
                          {
                        	  tittle="家具";
                          }
                          else if(type.equals("3"))
                          {
                        	  tittle="电脑";
                          }
                          else if(type.equals("4"))
                          {
                        	  tittle="点击最多";
                          }
                          else if(type.equals("5")){
                        	  tittle="限时特价";
                          }
                          else if(type.equals("6")){
                        	  tittle="最新上架";
                          }
                          else if(type.equals("7")){
                        	  tittle="相似商品";
                          }
                        %>
                        <li class="active"><a href="type.jsp>type=<%=type%>"><%=tittle %></a></li>
                       
                    </ul>
                </div>  
            </div>
        </div>
    </div> <!-- End mainmenu area -->


    
    <div class="product-big-title-area">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="product-bit-title text-center">
                        <h2>选你所选 定有心动</h2>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    
    <div class="single-product-area">
        <div class="zigzag-bottom"></div>
        <div class="container">
            <div class="row">
                  <!-- start -->       
               <%
                int pageNow=1;
                if(request.getParameter("pageNow")!=null){
                	 pageNow=Integer.parseInt(request.getParameter("pageNow"));
                }                 
                  int pageSize=5;
                  List<Good>goods=GoodsService.getGoods(pageNow, pageSize,type,key);
                  for(Good good:goods){
                	  
                %>
              <div class="col-md-3 col-sm-6">
                    <div class="single-product">
							<div class="product-f-image">
								<img src=<%=good.getPhotoPath() %>>
								<div class="product-hover">
									<a href="trolleyHandler?type=add&id=<%=good.getGoodId() %>" class="add-to-cart-link"><i class="fa fa-shopping-cart"></i> 加入购物车</a>
									<a href="singleProduct.jsp?id=<%= good.getGoodId() %>" class="view-details-link"><i class="fa fa-link"></i> 查看详情</a>
								</div>
							</div>		
							<div class="product-carousel-price">
								<ins></ins>						
							</div> 				
							<P style=font-size:20px><a   href="singleProduct.jsp?id=<%= good.getGoodId() %>" ><%=good.getName() %></a></P>						
							<div class="product-carousel-price">
								<ins style=font-size:18px><%=good.getPrice() %>元</ins>						
							</div> 
							<div class="product-carousel-price">
								<ins></ins>						
							</div> 
						
						</div>
                </div>        
                
               <%              	
                  }           
               %> 
               
                   <!-- end -->
            </div>
            
            <div class="row">
                <div class="col-md-12">
                    <div class="product-pagination text-center">
                        <nav>
                          <ul class="pagination">
                            <li>
                               <%                              
                               int pageCount=(GoodsService.getCount(type,key)+pageSize-1)/pageSize;                          
                                int previous;
                               if(pageNow==1){
                            	   previous=pageCount;
                               }
                               else{
                            	   previous=pageNow-1;
                               }                     
                               %>
                              <a href="type.jsp?pageNow=<%=previous %>&type=<%=type %>&key=<%= key%>">
                                <span>&laquo;</span>
                              </a>
                            </li>
                            <%      
                            int start=pageNow;
                            int end=pageNow+3;
                            if(end>=pageCount){                           	
                            	end=pageCount;                  
                            }
                            for(int i=start;i<=end;i++){
                            %>
                             <li><a href="type.jsp?type=<%=type %>&pageNow=<%=i%>&key=<%=key%>"><%=i%></a></li>                          
                            <%
                              }
                            %>
                         
                            <li>
                            <%     
                            int next;
                            if(pageNow==pageCount){
                            	next=1;                             	
                            }
                            else{
                            	next=pageNow+1;                           	
                            }
                             
                            %>
                              <a href="type.jsp?type=<%=type%>&pageNow=<%= next%>&key=<%=key%>">
                                <span>&raquo;</span>
                              </a>
                            </li>
                          </ul>
                        </nav>                        
                    </div>
                </div>
            </div>
        </div>
    </div>


 <div class="footer-top-area">
        <div class="zigzag-bottom"></div>
        <div class="container">
            <div class="row">
                <div class="col-md-3 col-sm-6">
                    <div class="footer-about-us">
                        <h2>声明<span></span></h2>
                        <p>本网站仅做测试使用，如有侵权，请联系我们。</p>
             
                    </div>
                </div>
                
                <div class="col-md-3 col-sm-6">
                    <div class="footer-menu">
                        <h2 align="center" class="footer-wid-title">如果不满意</h2>
                        <ul><li>
                          <div align="center"><a href="">淘宝</a></div>
                        </li>
                            <li>
                              <div align="center"><a href="">苏宁易购</a></div>
                            </li>
                            <li>
                              <div align="center"><a href="">58同城</a></div>
                            </li>
                            <li>
                              <div align="center"><a href="">转转</a></div>
                            </li>
                            <li>
                              <div align="center"><a href="">唯品会</a></div>
                            </li>
                        </ul>                        
                  </div>
                </div>
                
                <div class="col-md-3 col-sm-6">
                    <div class="footer-menu">
                        <h2 align="center" class="footer-wid-title">请点击这里</h2>
                    <ul>
                            <li>
                              <div align="center"><a href="">淘宝</a></div>
                        </li>
                          <li>
                            <div align="center"><a href="">京东</a></div>
                      </li>
                          <li>
                            <div align="center"><a href="">天猫</a></div>
                      </li>
                          <li>
                            <div align="center">蘑菇街<a href=""></a></div>
                          </li>
                        <li>
                              <div align="center"><a href="">赶集网</a></div>
                        </li>
                      </ul>                        
                    </div>
                </div>
                
                <div class="col-md-3 col-sm-6">
                    <div class="footer-newsletter">
                        <h2 align="center" class="footer-wid-title">或者联系我们</h2>
                      <p>如果你对我们的工作不满意，请输入您的建议</p>
                        <div class="newsletter-form">
                            <input type="email" placeholder="请输入您的建议">
                            <input type="submit" value="提交">
                        </div>
                    </div>
                </div>
            </div>
        </div>
</div>
  
   
   
  </body>
</html>